package src.C_io;

import java.io.Serializable;

// 被序列化的bean类需要实现Serializable接口
// ps：Serializable接口是没有抽象方法的，是一个标记型接口，一旦实现了这个接口就表示当前类可以被序列化
public class Demo13_Student implements Serializable {

    // 生成静态常量版本号（保证一次读写都是无修改的同一个版本），不生成get和set方法
    private static final long serialVersionUID = 6423946645585563032L;

    // ps：加了 transient 或 static 关键字的属性不会被序列化！
    private transient boolean flag; // transient 瞬态关键字
    static String address;
    private int age;
    private String name;
    private char sex;

    public Demo13_Student() {
    }

    public Demo13_Student(boolean flag, int age, String name, char sex) {
        this.flag = flag;
        this.age = age;
        this.name = name;
        this.sex = sex;
    }

    public boolean isFlag() {
        return flag;
    }

    public void setFlag(boolean flag) {
        this.flag = flag;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public char getSex() {
        return sex;
    }

    public void setSex(char sex) {
        this.sex = sex;
    }

    @Override
    public String toString() {
        return  serialVersionUID+"{" +
                "flag=" + flag +
                ", age=" + age +
                ", name='" + name + '\'' +
                ", sex=" + sex +
                ", address=" + address +
                '}';
    }
}
